package com.spbl.web;

import com.spbl.common.utils.JwtUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;

/**
 * Description(登录控制器)
 * author: Gao xueyong
 * Create at: 2020/5/30 2:33 下午
 */
@Slf4j
@Validated
@RestController
public class LoginController {

    @GetMapping("/login")
    public String login(@RequestParam("userName")  @NotBlank(message = "userName不能为null") String userName,
                        @RequestParam("password")  @NotBlank(message = "password不能为null")  String password) {
        log.info("userName={},password={}", userName, password);
        return JwtUtils.encryptRSA256Token(userName+password);
    }
}
